package com.lanwf.adminsuper.interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.lanwf.adminsuper.sys.utils.Cont;
import com.lanwf.adminsuper.sys.utils.GenUtil;

/**
 * @Auther: Lanwf
 * @Date: 2023/8/17 17:31
 * @Description: 未登录拦截器
 */
public class OutLoginRedirectInterceptor implements Interceptor {


    @Override
    public void intercept(Invocation invocation) {

        String uuid = invocation.getController().getCookie(Cont.SUPER_ADMIN_COOKIE);
        String username = GenUtil.cacheMap.get(uuid);
        if(username == null){
            invocation.getController().redirect("/super-admin/login");
            return;
        }
        invocation.invoke();
    }

}
